Skip to main content

All Questions

Tagged with
4votes
4answers
488views

Finding Special Parts in a Word

Task description: Imagine you have a long word made up of small letters like "a", "b", "c", ancd so on. Let’s call this word a puzzle word. We want to look at all the ...
CodeCrusader's user avatar
6votes
3answers
515views

locale-aware trim functions for std::string

I have written the below two trim functions for std::string and std::basic_string that are locale-aware. Both trim all white ...
digito_evo's user avatar
3votes
1answer
177views

Snail matrix in Java - version III (generalizing)

Once again, in the previous version, Alexander Ivanchenko helped me with his awesome answer. Now, I have improved the toString() and, also, generalized the class ...
coderodde's user avatar
2votes
3answers
697views

Step-by-step re-arranging of a string with randomized characters

A sloppy code featuring algorithms to efficiently randomize the characters of a string "Hello C" and then print out in the console the re-arrangement process for every character. ...
Edenia's user avatar
  • 1,578
4votes
2answers
485views

Z-Function/ Algorithms on strings. C++

The problem: Given a string s. For each i from 1 to |s|, find the number of occurrences of its prefix of length i in the string. Input: The first line of input contains an integer q (1≤q≤10⁵) — the ...
neely's user avatar
4votes
2answers
596views

O(nlogn) Lexicographically minimal rotation code but tle on this particular case

Based on a small suggestion here , this code tries to find lexicographically minimal rotation (question) by successively comparing two adjacent substrings in the very left , that can potentially give ...
Aryaman 's user avatar
-2votes
1answer
192views

Design an algorithm to predict words based on a skeleton from a given dictionary

The model I'm building first selects a secret word at random from a list. The model which uses an API then returns a row of underscores (space separated)—one for each letter in the secret word—and ...
driver's user avatar
2votes
3answers
140views

Print last lines of file

Task Write a Ruby function, which accepts a path to a text file and returns a string consisting of the last n lines in reversed order, separated by commas. Example input file: ...
michael.zech's user avatar
5votes
1answer
148views

Remove smiles from string in-place

I have a coding task. Remove smiles from string in-place. Smile is a set of characters starting from ':' and ending with one or more brackets ')' or one or more brackets '(' Example ...
mascai's user avatar
1vote
3answers
234views

Convert camelCase function name to snake_case

I have the following code: ...
TomS's user avatar
2votes
1answer
83views

Optimising function to strip honorifics from names

Problem I have a list of around ~1000 honorifics, see below for a sample. Given an input string of a name, for example ...
Ian's user avatar
  • 233
3votes
3answers
617views

Finding first unique character in string

Below is a solution I came up with (in C++) for an algorithm that is supposed to find the first character in a string that only appears once in the input string (the input string is guaranteed to be ...
tarstevs's user avatar
2votes
1answer
221views

Finding anagram groups using hashing and mapping the alphabet to random numbers

I was solving Group Anagram problem in leetcode. Link for the problem https://leetcode.com/problems/group-anagrams/ Below is the code which I wrote ...
susil95's user avatar
5votes
2answers
1kviews

Count each word within a string

I am looking for a solution with fewer lines of code. This is code that is working perfectly, but I think I typed too much for this algorithm. If I did something wrong, feel free to tell me the error. ...
Angel Abad's user avatar
2votes
1answer
158views

Golang solution to CTCI 1.2: Check whether two strings are permutations of each other

Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...
Sam Jing Wen's user avatar

153050per page
close